package demo4;

class Outer {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;
    static class InnerClass {
        public int data4 = 4;
        private int data5 = 5;
        public static int data6 = 6;

        public void func() {
            System.out.println("InnerClass::func");

            /**
             * 前者依赖对象,所以不能直接进行访问,需要使用外部类对象 + .
             */
            Outer outer = new Outer();
            System.out.println(outer.data1);
            System.out.println(outer.data2);
            System.out.println(data3);//static成员变量
            System.out.println(data4);//内部类变量...
            System.out.println(data5);
            System.out.println(data6);
        }
    }
    public void func() {
        System.out.println("Outer.func");
    }
}
public class Test {
    public static void main(String[] args) {
        /**内部类实例化
         * 外部类.内部类
         */
        Outer.InnerClass innerClass = new Outer.InnerClass();
        innerClass.func();
    }
}
